package com.photologics.logic;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Point;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageButton;

import com.photologics.main.R;

public class TileSelectDialog extends Dialog implements OnClickListener{
	private ImageButton check, decision;
	private LogicHelper.dragStyle dir;
	private Point base;
	private int length;
	public TileSelectDialog(Context context) {
		super(context);
	}
	public TileSelectDialog(Context context, LogicHelper.dragStyle dir, Point base, int length){
		super(context);
		
		this.dir = dir;
		this.base = base;
		this.length = length;
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.tile_select_dialog);
		
		check = (ImageButton)findViewById(R.id.imagebutton_check_tile);
		check.setOnClickListener(this);
		
		decision = (ImageButton)findViewById(R.id.imagebutton_black_tile);
		decision.setOnClickListener(this);
		
	}
	
	@Override
	public void onClick(View v) {
		if(v==check) {
			if (dir == LogicHelper.dragStyle.VERTICAL) 
				LogicActivity.changeVerticalTile(base, length, LogicHelper.tileState.CHECK, true);
			else 
				LogicActivity.changeHorizontalTile(base, length, LogicHelper.tileState.CHECK, true);
		}
		if(v==decision) {
			if (dir == LogicHelper.dragStyle.VERTICAL) 
				LogicActivity.changeVerticalTile(base, length, LogicHelper.tileState.DECISION, true);
			else 
				LogicActivity.changeHorizontalTile(base, length, LogicHelper.tileState.DECISION, true);
			
		}
		LogicActivity.setDialogOpen(false);
		dismiss();
	}
}
